#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

class Solution {
public:
    int tribonacci(int n) {
        if (n == 0) return 0;
        if (n == 1 || n == 2) return 1;
        int a = 0, b = 1, c = 1, d;
        for (int i = 3; i <= n; ++i)
        {
            d = a + b + c;
            a = b;
            b = c;
            c = d;
        }
        return d;
    }

    vector<int> findErrorNums(vector<int>& nums) {
        int n = nums.size();
        vector<int> ans(2);
        sort(nums.begin(), nums.end());
        int prev = 0;
        for (int i = 0; i < n; ++i)
        {
            int cur = nums[i];
            if (cur == prev) ans[0] = prev;
            else if (cur - prev > 1) ans[1] = prev + 1;
            prev = cur;
        }
        if (nums[n - 1] != n) ans[1] = n;
        return ans;
    }
};